package com.itrencai.d3_polymorphic.innerclass.anonymous;

import javax.swing.*;
import java.awt.event.ActionEvent;

public class Test3 {
    public static void main(String[] args) {
        //1.创建窗口
        JFrame win=new JFrame("登录界面");
        JPanel panel=new JPanel();
        win.add(panel);

        //2.创建一个按钮对象
        JButton btn=new JButton("登录");
        //注意:讲解匿名内部类的使用
/*        btn.addActionListener(new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
                JOptionPane.showMessageDialog(win,"点我一下，后果自负");
            }
        });*/

        btn.addActionListener(e->JOptionPane.showMessageDialog(win,"点我一下，后果自负"));






        //3.把按钮对象添加到桌布上展示
        panel.add(btn);

        //4.展示窗口
        win.setSize(400,300);
        win.setLocationRelativeTo(null);
        win.setVisible(true);
    }
}
